package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.constant.XiaoLiConstants;
import edu.langnan.xiaoli.core.dto.NucleicBaseInfoDTO;
import edu.langnan.xiaoli.core.dto.NucleicInfoDTO;
import edu.langnan.xiaoli.core.dto.TestPlaceDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.CollegeService;
import edu.langnan.xiaoli.service.NucleicAcidService;
import edu.langnan.xiaoli.service.TestPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/nucleic")
public class CommonNucleicAcidController extends BaseController {

    @Autowired
    private NucleicAcidService nucleicAcidService;

    @Autowired
    private TestPlaceService testPlaceService;


    /**
     * 分页获取核酸检测活动列表
     *
     * @return
     */
    @GetMapping("list")
    public TableDataInfo nucleicAcidList() {
        startPage();
        List<NucleicBaseInfoDTO> result = nucleicAcidService.nucleicAcidList();
        return getDataTable(result);
    }

    @GetMapping("{nid}")
    public AjaxResult findNucleicById(@PathVariable("nid") Integer nid) {
        NucleicInfoDTO result = nucleicAcidService.findNucleicById(nid);
        // 根据 nid 获取核酸检测活动地点
        List<TestPlaceDTO> testPlaces = testPlaceService.findTestPlaceListByNid(nid);

        result.setTestPlaces(testPlaces);
        return AjaxResult.success(result);
    }


}
